182247236
V2EX  ›  问与答

刚接触 python,想解决个问题

  •  
  •   182247236 · Oct 20, 2016 · 2717 views
    This topic created in 3675 days ago, the information mentioned may be changed or developed.
    PID = ‘lKGXIQa’
    GetUrl = ‘http://www.13235.com/liveforapp.php?cid='PID''
    print(GetUrl)
    我希望print出来的结果是http://www.13235.com/liveforapp.php?cid=lKGXIQa该怎么做,这算不算是在一个变量里面调用其他变量?
    16 replies  •  2016-10-20 18:51:45 +08:00
    kevinroot
    kevinroot
    Oct 20, 2016 via iPhone❤️1
    1
    刚接触 elixir ,想解决个问题
    182247236
    182247236
    OP
    Oct 20, 2016
    2
    @kevinroot 别闹 T,T
    182247236
    182247236
    OP
    Oct 20, 2016
    3
    问题是不是有点弱智都没人想达 TT
    jsonzz
    jsonzz
    Oct 20, 2016❤️1
    4
    WuMingyu
    WuMingyu
    Oct 20, 2016 via Android
    5
    搜索 python str format
    ex44559
    ex44559
    Oct 20, 2016❤️1
    6
    PID = 'lKGXIQa'
    GetUrl = 'http://www.13235.com/liveforapp.php?cid=' + PID
    print(GetUrl)

    这样也可以
    182247236
    182247236
    OP
    Oct 20, 2016
    7
    @jsonzz 还是不行,是因为实际上的 URL 应该是 GetUrl = 'http://www.13235.com/liveforapp.php?cid='PID'$appid=01' 这个 PID 是嵌在里面的。
    182247236
    182247236
    OP
    Oct 20, 2016
    8
    @ex44559 你这个方法好,以后可以用到,可是这次的 PID 是在 URL 里面的,不是在最后的,这样不行。
    182247236
    182247236
    OP
    Oct 20, 2016
    9
    @WuMingyu 谢谢,正需要这个,自己能查最好了
    Lonely
    Lonely
    Oct 20, 2016 via iPhone
    10
    搜索引擎不会用吗
    182247236
    182247236
    OP
    Oct 20, 2016
    11
    GetPlayer = "http://123324/liveforapp.php?cid=%s" %PID +'&appid=S01'最后这么解决的,@ex44559 你真聪明
    182247236
    182247236
    OP
    Oct 20, 2016
    12
    @Lonely 会用,可是不知道该搜什么,搜索怎么在一个变量里面调用另一个变量出来一大堆不懂得东西 TT
    harry890829
    harry890829
    Oct 20, 2016
    13
    占位符
    glasslion
    glasslion
    Oct 20, 2016❤️1
    14
    Using % and .format() for great good!
    https://pyformat.info/


    "http://123324/liveforapp.php?cid={cid}&appid={appid}" .format(cid=PID,appid="S01")
    182247236
    182247236
    OP
    Oct 20, 2016
    15
    谢谢
    kevinroot
    kevinroot
    Oct 20, 2016 via iPhone
    16
    我刚打开的时候显示只有主题没有内容,所以回复了一句 @Livid
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4648 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 01:25 · PVG 09:25 · LAX 17:25 · JFK 20:25
    ♥ Do have faith in what you're doing.