简体   繁体   中英

How to Format Python code as Python snippets on stack overflow?

How to format Python code as Python snippets on stack overflow since we can only do it as JavaScript or HTML or CSS snippets?

If you mean executable snippets, you can only do this with html / css / js :

 p { color: red; }
 <p>You can't do this with Python... sadly</p>

If you want to simply format a snippet, you can do this:

# This is Python code

printing this:

```python
# This is Python code
```

to do this you have to send key ctrl+k on a new line.

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