About 534,000 results
Open links in new tab
  1. python - Write variable to file, including name - Stack Overflow

    dict = {'one': 1, 'two': 2} What if I would like to write the exact code line, with the dict name and all, to a file. Is there a function in python that let me do it? Or do I have to convert it to a string first? Not a …

  2. python - Print a variable's name and value - Stack Overflow

    How can write a function that will take a variable or name of a variable and print its name and value? I'm interested exclusively in debugging output, this won't be incorporated into production code.

  3. python - How do I put a variable’s value inside a string (interpolate ...

    See for example How to use variables in SQL statement in Python? for proper techniques. If you just want to print (output) the string, you can prepare it this way first, or if you don't need the string for …

  4. How can I use a global variable in a function? - Stack Overflow

    Jul 11, 2016 · In Python, the module is the natural place for global data: Each module has its own private symbol table, which is used as the global symbol table by all functions defined in the module. …

  5. printing - Print variable and a string in python - Stack Overflow

    3 If the Python version you installed is 3.6.1, you can print strings and a variable through a single line of code. For example the first string is "I have", the second string is "US Dollars" and the variable …

  6. python - How to log a variable's name and value? - Stack Overflow

    Apr 10, 2019 · 16 I am looking for a way to quickly print a variable name and value while rapidly developing/debugging a small Python script on a Unix command line/ssh session. It seems like a …

  7. How can I use variables in an SQL statement in Python?

    I have the following Python code: cursor.execute ("INSERT INTO table VALUES var1, var2, var3,") where var1 is an integer. var2 and var3 are strings. How can I write the variable names wit...

  8. python - How to assign print output to a variable? - Stack Overflow

    The print statement in Python converts its arguments to strings, and outputs those strings to stdout. To save the string to a variable instead, only convert it to a string:

  9. How to write in .env file from python code - Stack Overflow

    Aug 19, 2020 · 9 os.environ is a Python dictionary containing the environment. In order to change the environment variables in your currently running process, and any children process spawned with , …

  10. Getting the name of a variable as a string - Stack Overflow

    Aug 25, 2013 · I already read How to get a function name as a string?. How can I do the same for a variable? As opposed to functions, Python variables do not have the __name__ attribute. In other …