简体   繁体   English

function str() 不起作用,我不知道该怎么办

[英]The function str() is not working and I do not know what to do

I have the code:我有代码:

def rides(x):
   return list(str(x))

When I input the word hi without any quotes当我输入单词 hi 时不带任何引号

It returns the error that hi is not defined它返回 hi 未定义的错误

However when input integers or hi with quotes it works, but I need it to work for hi without quotes.但是,当输入整数或带引号的 hi 时,它可以工作,但我需要它在不带引号的情况下为 hi 工作。

When your input is hi without quotes, it means you pass a variable named hi to your function.当您的输入是不带引号的hi时,这意味着您将一个名为hi的变量传递给您的 function。 If you don't define such variable before passing it to your function, your code will fail during it's evaluation with NameError error.如果您在将此类变量传递给 function 之前未定义此类变量,则您的代码将在评估期间因NameError错误而失败。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我不知道我的 function 出了什么问题 - I do not know what is wrong with my function str_to_a32-此功能做什么? - str_to_a32 - What does this function do? 我正在做一个 kivy 项目......我正在使用从函数创建的切换按钮......我怎么知道选择了什么? - im working on a kivy project... i am using toggle buttons that are create from a function... how do i know what is selected? 字典不工作,我也收到 'KeyError: 0' 错误消息,我不知道那是什么意思:/(顺便说一下 python) - Dictionaries are not working, also I am getting 'KeyError: 0' error messages and I do not know what that means :/ (python by the way) 我不知道如何向量化我的功能 - I do not know how to vectorize my function Python:_(“str”)做什么? - Python: What does _(“str”) do? 在Python(2.7.3)中,如果str(x)中的任何字符都在str(y)中(或str(y)在str(x)中),如何编写一个能够回答的函数? - In Python (2.7.3) how do I write a function that answers if any characters in str(x) are in str(y) (or str(y) are in str(x))? 我收到一条错误消息,指出 AttributeError: 'str' object has no attribute 'read',我不知道如何修复它 - I'm getting an error that says AttributeError: 'str' object has no attribute 'read' and i do not know how to fix it 我怎么知道wingware IDE使用python函数需要什么参数 - how do i know what parameters a python function takes with wingware IDE 如何在不引发UnicodeEncodeError的情况下覆盖str函数? - How do I override the str function without raising a UnicodeEncodeError?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM