推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
Newyorkcity
V2EX  ›  Python

请问“as if they were Python code”这句话(在回答 Input 和 raw_input 的区别时)该怎么理解?

  •  
  •   Newyorkcity · Jan 15, 2017 · 3310 views
    This topic created in 3594 days ago, the information mentioned may be changed or developed.

    What's the difference between input() and raw_input()?
    The input() function will try to convert things you enter as if they were Python code, but it has security problems so you should avoid it.


    from:https://learnpythonthehardway.org/book/ex11.html
    谢谢
    15 replies  •  2017-01-16 17:22:23 +08:00
    purebluesong
    purebluesong
    Jan 15, 2017
    1
    在 python2 中 input 会把读到的 python 代码跑起来
    Izual_Yang
    Izual_Yang
    Jan 15, 2017 via Android
    2
    一个是输入纯字符串所以是 raw ,一个是输入表达式所以有安全隐患。另外笨办法学 python 应该有中文翻译版本的吧
    lanlanlan
    lanlanlan
    Jan 15, 2017❤️1
    3
    input 会假设用户输入的是合法的 Python 表达式 而 raw_input 会把输入的内容当作原始数据 一般情况下多用 raw_input
    chuanqirenwu
    chuanqirenwu
    Jan 15, 2017 via iPhone
    4
    As if 只要
    congeec
    congeec
    Jan 15, 2017 via iPad
    5
    eval()
    redhatping
    redhatping
    Jan 15, 2017
    6
    as if 连词 = like (口语习惯)
    thekll
    thekll
    Jan 15, 2017
    7
    'like/as if/as though' is used to say how somebody or something looks/sounds/feels.
    'as if' and 'as though' are more formal than 'like'.

    After 'as if'(or 'as though'), we sometimes use the past when we are talking about the present.
    for example:
    'as if they were Python code'
    The meaning is not past in this sentence, We use the past('were') because the things you enter for the function input() is not really Python code, it will be converted and run.
    arischow
    arischow
    Jan 15, 2017 via iPhone❤️1
    8
    这个有翻译,看不懂可以先去看一眼翻译版本。
    shakespark
    shakespark
    Jan 15, 2017
    9
    虚拟语气
    zhidian
    zhidian
    Jan 15, 2017
    10
    as if 是“就像”吧。
    zingl
    zingl
    Jan 15, 2017
    11
    中学英语内容吧
    N0stalgia
    N0stalgia
    Jan 15, 2017
    12
    生硬的翻译下,就好像 Python 代码一样。
    msg7086
    msg7086
    Jan 16, 2017
    13
    as 表示类比。
    if 表示假设。
    连在一起:「就好像」。
    hihihihihi
    hihihihihi
    Jan 16, 2017
    14
    假如,如果
    20150517
    20150517
    Jan 16, 2017 via iPhone
    15
    as if 就好像 我是这么理解的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4337 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 58ms · UTC 08:15 · PVG 16:15 · LAX 00:15 · JFK 03:15
    ♥ Do have faith in what you're doing.