I'm trying to say "Welcome USERNAME ", but I don't know
what to put as " USERNAME ". Is it even possible to get the user's repl username in python?
OHHHHHHH. I see, it wasn't, "environ()" but, "environ[]". BRUH TO ME. @EpicRaisin and @RYANTADIPARTHI Sorry for being blind.
Does it work for any user though? As in, if a different user's name was Johny, would it say Johny or would it say "HoogidyBoogidy"? If it doesn't work like that, then I need something else.
@HoogidyBoogidy lol its ok
Gives you HoogidyBoogidy. If you want the name, you can't anymore due to repl.it shutting down their api to the public @HoogidyBoogidy
Solution
Try this:
import os
owner = os.environ['REPL_OWNER']
# to print, use owner
print("hello " + owner)
like that.
That should work
I believe it's this:
import os
user = os.environ["REPL_OWNER"]
I tried "print(os.environ("REPL_OWNER"))", but still didn't work.
@HoogidyBoogidy It's not os.environ('REPL_OWNER')
, it's a dictionary, so it's os.environ['REPL_OWNER']
.
EDIT:
ok justification for why
REPL_OWNER
works.Each time someone views ur repl, they 'fork' it without even them knowing it. This fork will be deleted after they leave, but they need to fork it so the program even can be run. Now your can get any user name!