python在文本添加超链接_Python将超链接文本打印到Spyder控制台(Python print hyperlinked text to Spyder Console)...
Python將超鏈接文本打印到Spyder控制臺(Python print hyperlinked text to Spyder Console)
我在Windows 7上使用WinPython發行版,它隨Spyder IDE一起提供(我希望它在Anaconda上也能正常工作)。 我想知道如何將超鏈接文本打印到控制臺輸出。
我認為這是可能的,因為當我在我的代碼中出現錯誤時,我得到了回溯,它顯示了它崩潰的位置,并且這些鏈接是可點擊的,然后將打開引發錯誤的函數行。 見下文:
(我不能在沒有10個代表的情況下發布圖片,這是蹩腳的,我是網站的新手)請看這里: http : //i.stack.imgur.com/oJ3Aw.png
但是,我不想只在IDE中打開一個文件,我想要做的是有一個指向文件夾位置的鏈接,我的代碼只是將一些繪圖圖像保存到磁盤,當我點擊鏈接時,有它在Windows資源管理器中打開該文件夾。 如果存在獨立于平臺的方式,那么獎勵積分,但僅限Windows的解決方案對我來說就足夠了。
我有一些以前存在的Matlab代碼可以為我做這個,但我無法確定是否有Python等價物:
save_path = pwd;
fprintf('Plots saved to: %s\n',save_path,save_path);
I'm using the WinPython distribution on Windows 7, which comes with the Spyder IDE (and I hope this will work the same on Anaconda). I would like to know how to print hyperlinked text to the console output.
I assume it's possible, because when I get an error in my code, I get the traceback that shows me where it crashed, and those links are clickable, and will then open the line of the function where it raised the error. See below:
(I can't post the image without 10 rep, that's lame, I'm new to the site) See here: http://i.stack.imgur.com/oJ3Aw.png
However, I don't want to just open a file within the IDE, what I want to do is have a link to the folder location where my code just saved some plot images to disk, and when I click on the link, have it open the folder within windows explorer. Bonus points if there is a platform independent way of doing this, but a windows only solution would be sufficient for me.
I have some previously existing Matlab code that would do this for me, but I can't determine if there is a Python equivalent:
save_path = pwd;
fprintf('Plots saved to: %s\n',save_path,save_path);
原文:https://stackoverflow.com/questions/31975741
更新時間:2020-01-29 20:11
相關問答
你該走了 Run > Configuration per file (或者Ctrl+F6 ),然后在出現的對話框中查看 Command line options 并在那里寫(例如) 1 2 3 關閉這個對話框并點擊F5 ,你會看到你期待的輸出。 注意 :請記住,這些命令行選項是作為文件運行配置的一部分保存在Spyder重啟之間的,所以如果你想改變它們,你需要再次點擊Ctrl+F6 。 You need to go Run > Configuration per file (or hit Ctrl+
...
( Spyder維護者在這里 )不,不幸的是沒有辦法再添加它。 我們決定刪除它,因為Python控制臺存在所有問題,正如您在上面提到的問題中提到的那樣。 (Spyder maintainer here) No, unfortunately there's no way to add it back again. We decided to remove it because of all the problems the Python console had, as mentioned in th
...
非常有趣的問題! 幸運的是,IPython擁有適合您的魔力。 它被稱為%logstart (請點擊完整文檔的鏈接)。 要開始使用它并保存所有命令的輸入和輸出,只需鍵入IPython控制臺即可 In[1]: %logstart -o
并且會將您當時的會話記錄到當前目錄中名為ipython_log.py的文件中。 %logstart非常靈活,因此您可以選擇要保存的其他文件,以及如何保存會話(純Python或IPython命令)。 Very interesting question! Fortunat
...
( Spyder開發者在這里 )這是一個已知的問題,我們正在努力解決它。 不幸的是,我們仍在試圖找出問題的根源。 注意 :這只發生在Windows上。 其他平臺不受此問題的影響。 (Spyder developer here) This is a known problem and we're working to fix it. Unfortunately, we are still trying to find the source of the problem. Note: This onl
...
它已被棄用。 我在這里找到了一個參考: https : //github.com/pydata/pandas/pull/7499#issue-36016539 It has been deprecated. I find a reference here: https://github.com/pydata/pandas/pull/7499#issue-36016539
我正在運行不同版本的Spyder和Python,但能夠重現你的問題。 確保您始終運行iPython控制臺,這將確保您不會收到此錯誤。 這將有助于重新打開spyder。 I'm running a different version of Spyder & Python but was able to repro your issue. Make sure you always have an iPython console running, this will make sure you don'
...
( Spyder維護者在這里 )為了避免Spyder中的這個問題,我們一次只允許在控制臺中顯示500行( 注意 :此限制可由用戶配置) 所以我會說Pycharm的控制臺沒有這個功能(雖然我無法確定)。 (Spyder maintainer here) To avoid this problem in Spyder we only allow 500 lines to be shown in the console at a time (Note: This limit is configurabl
...
( Spyder開發人員在這里 )您需要將qtconsole軟件包更新到其版本4.3以修復此錯誤。 如果您使用的是Anaconda,則需要打開終端( cmd.exe )并運行此命令 conda update qtconsole
如果沒有,你需要運行 pip install -U qtconsole
(Spyder developer here) You need to update the qtconsole package to its version 4.3 to fix this err
...
您可以在運行 - >配置(F6)中指定Spyder的運行設置。 默認情況下,選擇“在當前Python或IPython控制臺中執行”,您可能在Spyder中沒有任何打開的控制臺。 您可以選擇“在新的專用Python控制臺中執行”選項,Spyder將自動為您打開一個新控制臺。 或者您可以離開dafault選項并在控制臺菜單中自己創建一個新控制臺。 You can specify the Spyder's Run Settings in Run -> Configure (F6). By default
...
好吧,通常要完成它,你必須重寫python print內置函數。 但是......有ipython,它提供了一些鉤子。 首先你需要安裝ipython : #bash
sudo pip install ipython
(我使用sudo來簡單找到我需要訪問的文件夾,進一步閱讀) 在ipython安裝之后,您將擁有ipython擴展文件夾,所以請訪問它: #bash
cd ~/.ipython/extensions/
并在那里創建一個名為print_to_file.py的文件,這里是它的內容: #p
...
總結
以上是生活随笔為你收集整理的python在文本添加超链接_Python将超链接文本打印到Spyder控制台(Python print hyperlinked text to Spyder Console)...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 升级电脑必备!4个内存槽让你的电脑性能飙
- 下一篇: websocket python爬虫_p