Skip to content

how to run python input function?  #17

Open

Description

@Sunny-guangge
No description provided.

Activity

  1. Sunny-guangge commented on Feb 29, 2024

    @Sunny-guangge
    Author

    def main():
    # print('00')
    n1 = 10
    n2 = 20
    print(n1, '+', n2, '= ?')
    a = input('send something')
    a = int(a)
    b = n1 + n2
    if b == a:
    print('good!')
    else:
    print('sorry', b)

    in ios project how to implement the input function

  2. kewlbear commented on Mar 4, 2024

    @kewlbear
    Owner

    You can build UI using SwiftUI or UIKit and pass user input to Python code.

  3. Sunny-guangge commented on Mar 11, 2024

    @Sunny-guangge
    Author

    You can build UI using SwiftUI or UIKit and pass user input to Python code.

    but How to maintain the python running environment? When I receive a prompt to 'send something' and then enter a number, continue executing the subsequent python code?

  4. kewlbear commented on Mar 11, 2024

    @kewlbear
    Owner

    I see. So you want to keep using standard input/output. I guess it's possible but not easy. You can make a Pipe object and replace file descriptors of standard input/output with pipe's. Then either handle events or utilize async/await.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions