【问题标题】:Is there any way to print something without using any strings or numbers in Python?有没有什么方法可以在不使用 Python 中的任何字符串或数字的情况下打印一些东西?
【发布时间】:2019-01-10 01:40:16
【问题描述】:

有什么方法可以打印不使用 "' 或数字的东西(比如Hello World!)?

这是针对我正在做的当前DMOJ 问题。这是问题所在:Too Simple

现在,人们可能会说,“哦。好吧。我可以做类似的事情

from lxml import html
import requests

page = requests.get('https://Too-Simple-Site--ariari.repl.co/index.html')
tree = html.fromstring(page.content)

hello = tree.xpath('//div[@title="buyer-name"]/text()')

for char in hello: 
  print (char, end='')

并解决这个问题。但是,问题是只允许使用内置模块。那么,我该怎么做呢?

非常感谢。

【问题讨论】:

标签: python string numbers


【解决方案1】:

(作为解决这个问题的人)

这个问题其实出乎意料的简单,实际上你只需要知道三件事:

  1. True 转换为整数时的值为 1
  2. 您可以使用chr 函数将字符代码(整数)转换为字符
  3. 您不必自己手动编写代码,您可以随时编写程序来生成代码。

显然还需要有关字符串的基本知识(字符代码是什么等)。

祝你好运!

编辑:一旦你知道了这些事情,拼凑出一个解决方案应该不会太难

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-01-18
    • 2017-04-22
    • 2017-07-20
    • 2020-09-13
    • 1970-01-01
    • 2023-03-18
    • 1970-01-01
    相关资源
    最近更新 更多