简体   繁体   中英

AttributeError: module 'test' has no attribute 'randhiletter'

I am getting the error, in the title , even though there is a function randhiletter in the python file test.py. I am using this code in the file accessing test.py:

import test
print(test.randhiletter())

The code in test.py basically uses randint to assign a variable a number. Based on that number it will return a letter. There are two functions in test.py. These are randhiletter and randlowletter which do the same thing but for lowercase and uppercase letters. I do not understand why I am getting the error.

Credits to user2357112 supports Monica for this answer. He/she did not post one so I felt that I should to close the discussion or something: The issue was that I could not use the name test for the file I was trying to import as that is apparently already a python library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM