python - 如何将一个模块的变量添加到python中的另一个maodule
问题描述
我想将一个变量从一个模块添加到另一个模块,
同时我对声明变量有疑问。**
这是我的主要节目
import check
print("enter your name")
name=input()
if check.users:
print("nice to see yo again")
else :
print("nice to meet you")
这是我的另一个文件 check.py
import new
users = name=="venkatesh" or name=="rishi" or name=="arjun"
但编译器显示错误消息:
CHECK MODULE HAS NO ATTRIBUTE OF USERS
解决方案
我想你需要这样的东西
new.py
文件。
import check
user = check.user
print("enter your name")
name=input()
if check.users:
print("nice to see yo again")
else :
print("nice to meet you")
check.py
文件
user = "Enter name of the User"
# Your check condition
推荐阅读
- django - 在邮递员中获得预期的卷曲输出..但在使用 django view.py 时不一样
- java - Spring kafka:如何在生产者工厂中配置序列化器?
- php - 如何将自定义元过滤器添加到 WooCommerce Analytics?
- pandas - 如何将我从汤收集的数据附加到数据框?
- android-10.0 - 使用 pm list packages 不显示的隐藏包
- laravel - 配置对象无效。对象已初始化('webpackbar')
- flutter - 如何在颤动中对来自firebase的多个值求和
- c# - 尝试在 Entity Framework 6 中启用自动迁移时出现 System.NotSupportedException
- ansible - 无法在清单文件中的远程主机上安装 httpd
- javascript - 使用按钮创建输入并添加到数组 Javascript