推荐学习书目
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 · 2967 views
    This topic created in 3420 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
        1
    purebluesong  
       Jan 15, 2017
    在 python2 中 input 会把读到的 python 代码跑起来
    Izual_Yang
        2
    Izual_Yang  
       Jan 15, 2017 via Android
    一个是输入纯字符串所以是 raw ,一个是输入表达式所以有安全隐患。另外笨办法学 python 应该有中文翻译版本的吧
    lanlanlan
        3
    lanlanlan  
       Jan 15, 2017   ❤️ 1
    input 会假设用户输入的是合法的 Python 表达式 而 raw_input 会把输入的内容当作原始数据 一般情况下多用 raw_input
    chuanqirenwu
        4
    chuanqirenwu  
       Jan 15, 2017 via iPhone
    As if 只要
    congeec
        5
    congeec  
       Jan 15, 2017 via iPad
    eval()
    redhatping
        6
    redhatping  
       Jan 15, 2017
    as if 连词 = like (口语习惯)
    thekll
        7
    thekll  
       Jan 15, 2017
    '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
        8
    arischow  
       Jan 15, 2017 via iPhone   ❤️ 1
    这个有翻译,看不懂可以先去看一眼翻译版本。
    shakespark
        9
    shakespark  
       Jan 15, 2017
    虚拟语气
    zhidian
        10
    zhidian  
       Jan 15, 2017
    as if 是“就像”吧。
    zingl
        11
    zingl  
       Jan 15, 2017
    中学英语内容吧
    N0stalgia
        12
    N0stalgia  
       Jan 15, 2017
    生硬的翻译下,就好像 Python 代码一样。
    msg7086
        13
    msg7086  
       Jan 16, 2017
    as 表示类比。
    if 表示假设。
    连在一起:「就好像」。
    hihihihihi
        14
    hihihihihi  
       Jan 16, 2017
    假如,如果
    20150517
        15
    20150517  
       Jan 16, 2017 via iPhone
    as if 就好像 我是这么理解的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3338 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 63ms · UTC 11:08 · PVG 19:08 · LAX 04:08 · JFK 07:08
    ♥ Do have faith in what you're doing.