小编use*_*501的帖子

语法无效?

由于某种原因,我在 Debian 上不断收到代码无效语法错误。但当我在 Mac 上运行它时,没有发生任何错误,并且运行顺利。你们能帮我吗?

def read_config(cfg='~/instacron/config.txt'):
    """Read the config.

    Create a config file at `cfg` with the
    following information and structure:
        my_user_name
        my_difficult_password
    """
    import os.path
    _cfg = os.path.expanduser(cfg)
    try:
        with open(_cfg, 'r') as f:
            user, pw = [s.replace('\n', '') for s in f.readlines()]
    except Exception:
        import getpass
        print(f"\nReading config file `{cfg}` didn't work")
        user = input('Enter username and hit enter\n')
        pw = getpass.getpass('Enter password and hit enter\n')
        save_config = input(
            f"Save to config file `{cfg}` (y/N)? ").lower() == …
Run Code Online (Sandbox Code Playgroud)

python syntax

2
推荐指数
1
解决办法
184
查看次数

标签 统计

python ×1

syntax ×1