Annoying experience with pygal

Recently,I have been learning pygal according to the book.And I installed the pygal as the book said,this is my code:

pip install --user pygal==1.7

But ,when I try to use it and ran this code:

hist.render_to_file('1.svg') 

It failed,and threw the exception:
这里写图片描述

I was annoyed and upset for days.
And I try to solved it by asking in many place,but nobody answered me.

Until today’s morning,when I go to stackoverflow ,I found someone answered my question.By his help,I have solved it successfully!Thanks to him~~~

This is the link:
https://stackoverflow.com/questions/45520049/pygal-valueerror-invalid-pi-name-bxml?noredirect=1#comment78034432_45520049

My problem is that the version of pygal is too low to work with python3.5.
So,I uninstall the old version:

pip uninstall pygal

And the install the newest version by this way:

pip install --user pygal==2.4 

Finally ,It works properly!!!

这里写图片描述

(I am a Chinese,but there is a problem with the input method in ubuntu,so I use English.And my English is poor,If there’re some mistakes,please ignore it~)

  • 9
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 12
    评论
可以使用深度优先搜索(DFS)来解决这个问题。首先,我们可以将问题抽象为一个图,其中每个房间都是一个节点,相邻房间之间有边相连。 首先,我们需要定义一个辅助函数,用于检查给定的坐标是否在合法的范围内: ```cpp bool isValid(int x, int y, int n, int m) { return (x >= 1 && x <= n && y >= 1 && y <= m); } ``` 接下来,我们可以使用DFS来遍历所有可能的移动方式。我们从Vika的起始位置开始,依次向四个方向移动,然后递归地对每个朋友进行相同的操作。如果在递归过程中,任何一个朋友与Vika在同一个房间,则说明Vika会被抓住。 以下是完整的C++代码实现: ```cpp #include <iostream> #include <vector> using namespace std; bool isValid(int x, int y, int n, int m) { return (x >= 1 && x <= n && y >= 1 && y <= m); } bool dfs(int vx, int vy, vector<pair<int, int>>& friends, vector<vector<bool>>& visited, int n, int m) { if (vx == 0 && vy == 0) { // Vika has successfully escaped return true; } visited[vx][vy] = true; // Possible neighbors' coordinates vector<pair<int, int>> neighbors = {{vx-1, vy}, {vx+1, vy}, {vx, vy-1}, {vx, vy+1}}; for (auto neighbor : neighbors) { int nx = neighbor.first; int ny = neighbor.second; if (isValid(nx, ny, n, m) && !visited[nx][ny]) { bool caught = false; for (auto friendCoord : friends) { int fx = friendCoord.first; int fy = friendCoord.second; if (nx == fx && ny == fy) { caught = true; break; } } if (!caught && dfs(nx, ny, friends, visited, n, m)) { return true; } } } return false; } string canVikaEscape(int n, int m, int vx, int vy, vector<pair<int, int>>& friends) { vector<vector<bool>> visited(n+1, vector<bool>(m+1, false)); if (dfs(vx, vy, friends, visited, n, m)) { return "Yes"; } else { return "No"; } } int main() { int n, m, vx, vy, k; cin >> n >> m >> vx >> vy >> k; vector<pair<int, int>> friends(k); for (int i = 0; i < k; i++) { cin >> friends[i].first >> friends[i].second; } cout << canVikaEscape(n, m, vx, vy, friends) << endl; return 0; } ``` 该代码首先读取输入的n,m,vx,vy和k值。接下来,它读取k个朋友的坐标,并调用canVikaEscape函数来判断Vika是否能逃脱。最后,它输出结果。 希望这可以帮助到你!
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值